import { BasicColumn } from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { UploadBizType } from '/@/enums/uploadEnum';

export const columns: BasicColumn[] = [
  // {
  //   title: 'ying',
  //   dataIndex: 'avatar',
  //   width: 80,
  //   customRender: (record) => {
  //     return render.renderAvatar(record)
  //   },
  // },
  {
    title: '应用名称',
    dataIndex: 'name',
    width: 100,
  },
  {
    title: '状态',
    dataIndex: 'status',
    customRender: ({text}) => {
      let color = 'green'
      if (text === '2') {
        color = 'red'
      }
      return render.renderTag(render.renderDict(text, 'data_use_status'), color)
    },
    width: 60,
  },
  {
    title: '创建时间',
    dataIndex: 'createdAt',
    width: 130,
  },
  {
    title: '创建者',
    dataIndex: 'createdBy',
    width: 130,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '应用名',
    field: 'appName',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode:'use_status',
      placeholder:'请选择状态',
      stringToNumber:true
    }
  }
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '应用名称',
    field: 'name',
    required: true,
    component: 'Input',
    // dynamicRules: ({model,schema}) =>rules.duplicateCheckRule("sys_microApp", "microAppName",model,schema,true),
  },
  {
    label: '首页地址',
    field: 'appUrl',
    required: true,
    // rules: rules.rule('http',true),
    component: 'Input',
  },
  {
    label: '应用图标',
    field: 'appLogo',
    component: 'MyImageUpload',
    componentProps: {
      fileMax:1,
      bizType: UploadBizType.GENERAL_IMAGE
    },
  },
  {
    field: 'sortNo',
    label: '排序',
    component: 'InputNumber',
    defaultValue: 1,
  },
  {
    label: '能否删除',
    field: 'canDelete',
    component: 'JDictSelectTag',
    defaultValue: '1',
    componentProps: {
      type: "radio",
      dictCode: 'bool_value',
    },
    colProps: {span: 12}  
  },
  {
    label: '能否更新',
    field: 'canUpdate',
    component: 'JDictSelectTag',
    defaultValue: '1',
    componentProps: {
      type: "radio",
      dictCode: 'bool_value',
    },
    colProps: {span: 12}
  },
  {
    label: '是否隐藏',
    field: 'isHidden',
    component: 'JDictSelectTag',
    defaultValue: '0',
    componentProps: {
      type: "radio",
      dictCode: 'bool_value',
    },
    colProps: {span: 12}
  },
  {
    label: '外部打开',
    field: 'isExternal',
    component: 'JDictSelectTag',
    defaultValue: '0',
    componentProps: {
      type: "radio",
      dictCode: 'bool_value',
    },
    colProps: {span: 12}
  },
  {
    label: '应用状态',
    field: 'status',
    component: 'JDictSelectTag',
    defaultValue: '1',
    componentProps: {
      type: "radio",
      dictCode: 'data_use_status',
    },
    colProps: {span: 12}
  },
  {
    label: '应用描述',
    field: 'appDesc',
    component: 'InputTextArea',
    componentProps: {
      autoSize: {
        minRows: 3,
        maxRows: 6
      }
    }
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea'
  }
];

/**
 * 搜索用户
 */
export const searchMicroAppFormSchema: FormSchema[] = [
  {
    field: 'microAppName',
    label: '用户账号',
    component: 'Input',
    colProps: { span: 12 },
  },

];
